﻿//--------------------------------------------------------------------------
// 
//  Copyright (c) Chili Software.  All rights reserved. 
// 
//  File: IMemberInfoCollection.cs
//
//  Description: Holds all mapped members of the persistent object.
// 
//--------------------------------------------------------------------------

using System;
using System.Collections.Generic;
namespace Chili.Opf3.Mapping
{
	/// <summary>
	/// Interface that represents a collection of <see cref="IMemberInfo">IMemberInfo</see> objects.
	/// </summary>
	/// <remarks>
	/// This interface represents a collection of <see cref="IMemberInfo">IMemberInfo</see> objects. An instance of this class 
	/// is stored as list of all mapped object elements with an instance of the 
	/// <see cref="TypeMapping">TypeMapping</see> class.
	/// </remarks>
	public interface IMemberInfoCollection : IEnumerable<IMemberInfo>
	{
		/// <summary>
		/// Determines whether an element is in the collection.
		/// </summary>
		/// <param name="item">The object to locate in the collection.</param>
		/// <returns>True if item is found in the collection; otherwise, false.</returns>
		bool Contains(IMemberInfo item);

		/// <summary>
		/// Copies the entire collection to a compatible one-dimensional array, starting at the specified index of the target array.
		/// </summary>
		/// <param name="array">The one-dimensional System.Array that is the destination of the elements copied from collection. The System.Array must have zero-based indexing.</param>
		/// <param name="arrayIndex">The zero-based index in array at which copying begins.</param>
		void CopyTo(IMemberInfo[] array, int arrayIndex);

		/// <summary>
		/// Gets the number of elements actually contained in the collection.
		/// </summary>
		int Count { get; }

		/// <summary>
		/// Returns a list that contains the member mappings for the identifier member of the type.
		/// </summary>
		IIdentifierMemberInfoCollection GetIdentifierMemberMappings();

		/// <summary>
		/// Returns the <see cref="IMemberInfo">IMemberInfo</see> object associated with the given field name.
		/// </summary>
		/// <param name="fieldName">The name of the field in the storage.</param>
		/// <returns>An instance of the <see cref="IMemberInfo">IMemberInfo</see> class associated with the given field name.</returns>
		IMemberInfo GetMemberInfoByField(string fieldName);

		/// <summary>
		/// Returns the <see cref="IMemberInfo">IMemberInfo</see> object associated with the given name of an object member.
		/// </summary>
		/// <param name="memberName">The name of an object member (a property or a field).</param>
		/// <returns>An instance of the <see cref="IMemberInfo">IMemberInfo</see> class associated with the given object member.</returns>
		IMemberInfo GetMemberInfoByName(string memberName);

		/// <summary>
		/// Returns whether the collection is read-only.
		/// </summary>
		bool IsReadOnly { get; }

		/// <summary>
		/// Returns the item at the given index.
		/// </summary>
		/// <param name="index">The index of the item that is returned.</param>
		/// <returns>The item at the given index.</returns>
		IMemberInfo this[int index] { get; }
	}
}
